package com.dosin.crowno.service;

import com.dosin.crowno.dao.UserAccountMapper;
import com.dosin.crowno.pojo.UserAccount;
import com.sun.org.apache.xpath.internal.functions.FuncFalse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UserAccountService {

    @Autowired
    private UserAccountMapper userAccountMapper;


    public UserAccount userAndPass(String username,String password){

        return userAccountMapper.selectByUserAndPass(username, password);
    }

    public boolean login(String username, String password) {
        boolean b;
        try {
            UserAccount user = userAccountMapper.selectByUserAndPass(username, password);
             b = username.equals(user.getUsername()) && password.equals(user.getPassword());
        }catch (Exception e){
            b = false;
        }

        return b;

    }

    public Date now(){

      return userAccountMapper.now();
    }


 /*   public int insertSelective(UserAccount record){

        return userAccountMapper.insertSelective(record);
    }*/

    public int updateByPrimaryKeySelective(UserAccount record){
        return userAccountMapper.updateByPrimaryKeySelective(record);
    }
}
